﻿@using Board.Models
@{
    Layout = null;
}

@if (ViewBag.User != null)
{
    WebUser user = (WebUser) ViewBag.User;
    <text>
        @Html.Hidden("userId", user.UserId+"")
        <div id="permissionDetailDiv">
            <table>
                <thead>
                    <tr>
                        <th>Site</th>
                        <th>Unit</th>
                        <th>Bed</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (t_UnitBedPermission up in user.Permissions)
                    {
                        <text>
                            <tr>
                                <td>@up.SiteID</td>
                                <td>@up.UnitID</td>
                                <td>@up.Bed</td>
                                <td><a id="up@(up.BoardId)" class="delete-permission" href="javascript:void(0);">Delete</a></td>
                            </tr>
                        </text>
                    }
                </tbody>
            </table>
        </div>
    </text>
}
else
{
    <text>
        Invalid User.
    </text>
}

<div>
    <div class="float-left">Add permission: </div> 
    <div id="SiteDiv" class="float-left">@Html.DropDownList("Site", (IEnumerable<SelectListItem>)(ViewBag.SiteDropdown))</div>
    <div id="UnitDiv" class="float-left">@Html.DropDownList("Unit", (IEnumerable<SelectListItem>)(ViewBag.UnitDropdown))</div>
    <div id="BedDiv" class="float-left">All Beds @Html.Hidden("Bed", Bed.ALL_BEDS)</div>
    <div id="addPermission" class="float-left"><button>Add</button></div>
</div>
<div class="error">@ViewBag.Message</div>
@Html.Hidden("Usage", "1")
<script> UpdateAccountControls();</script>
